

import 'package:baselib/utils/load_util.dart';
import 'package:baselib/utils/log_util.dart';
import 'package:baselib/utils/navigator_util.dart';
import 'package:baselib/utils/toast_util.dart';
import 'package:framelib/base/base_view_model.dart';
import 'package:framelib/config/api_config.dart';
import 'package:framelib/net/baseentity.dart';
import 'package:framelib/utils/nim_sdk_util.dart';
import 'package:framelib/utils/string_util.dart';
import 'package:get/state_manager.dart';
import 'package:get/get.dart';
import 'package:module_business/module_comm/model/user_params_model.dart';
import 'package:module_business/module_index/model/index_room_item_entity.dart';
import 'package:module_business/module_index/model/voice_person_entity.dart';
import 'package:module_business/module_index/service/module_index_service.dart';
import 'package:nim_core/nim_core.dart';

class ReportViewModel extends BaseViewModel<ModuleIndexService>{

  ModuleIndexService moduleIndexService;
  String reports = '';
  String beBlockUid='';
  List<String> reportTags = [
    'Political sensitivity',
    'Violent pornography',
    'Advertising harassment',
    'Other'
  ];
  RxInt selectedTagIndex = (-1).obs;

  @override
  ModuleIndexService createService() =>moduleIndexService = ModuleIndexService();
  @override
  void onInit() {
    super.onInit();
    Map<String,dynamic> arguments = Get.arguments??{};
    beBlockUid =  arguments['beBlockUid'];
  }
  @override
  void onClose() {
    super.onClose();
  }

  inputChange(value) {
    reports = value;
  }

  submit() async{
    if(selectedTagIndex.value==(-1)){
      ToastUtil.toast('${StringUtil.instance.Please_select_feedback_type} ');
      return;
    }
    if((reports??'').isEmpty){
      ToastUtil.toast('${StringUtil.instance.Describe_more_clear_reporting_information}');
      return;
    }
    LoadUtil.showLoad(loadingText: StringUtil.instance.Downmicing);
    Map<String,dynamic> upData= {
      "beBlockUid": beBlockUid,
      //是否拉黑(1：是，2：否),示例值(1)
      "block": 2,
      "feedbackType": reportTags[selectedTagIndex.value],
      "suggestion": reports,
      "url": ""
    };
    BaseEntity baseEntity = await moduleIndexService.
    api_feedback_feedbackVideo(parmsMap: upData);
    LoadUtil.hideLoad();
    if(baseEntity?.code == ApiConfig.SUCCESS_CODE){
      ToastUtil.toast(StringUtil.instance.Report_Success);
      NavigatorUtil.goBack();
    }else{
      ToastUtil.toast(baseEntity?.message);
    }
  }

  tagItemTap(int index) {
    selectedTagIndex.value = index;
  }
}
